package com.fi.recogn.dto.table;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Objects;

/**
 * @author songqiang
 * @desc 标题命中关联字段
 * @created on 2023 年 11 月 07
 * @Date 9:17
 * @since 1.0
 */

@Data
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class HitWord implements Serializable {

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty("关联关系id")
    private Long id;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty("后台表id")
    private Long backendId;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty("后台表定义字段id")
    private Long backendWordId;

    @ApiModelProperty("后台表关键字条件id")
    private Integer conditionId;

    @ApiModelProperty("操作用户id")
    @JsonIgnore
    private Integer userId;

    @ApiModelProperty("取值方式，0：默认取值，1：对本单元格取值")
    private Integer getValueType;

    public HitWord(Long backendId, Long backendWordId, Integer conditionId) {
        this.backendId = backendId;
        this.backendWordId = backendWordId;
        this.conditionId = conditionId;
    }


    @Override
    public int hashCode() {
        return Objects.hash(backendId, backendWordId);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof HitWord)) {
            return false;
        }
        HitWord obj1 = (HitWord) obj;
        return Objects.equals(backendId, obj1.getBackendId()) && Objects.equals(backendWordId, obj1.getBackendWordId());
    }

}
